
<h3>프로젝트: <%= @project.name %></h3>

<ul class="nav nav-tabs" style="margin-bottom: 20px;">
	<li class="active">
		<a href="#files" data-toggle="tab"><h4>모니터링 파일</h4></a>
	</li>
	<li>
		<a href="#members" data-toggle="tab"><h4>프로젝트 참가자</h4></a>
	</li>
</ul>

<div class="tab-content" >
	<div class="tab-pane active" id="files">

		<table class="table table-hover">
			<tr>
				<th>파일명</th>
				<th>업로드한사용자</th>
				<th>업로드시각</th>
			</tr>
			<% @monitoring_files.each do | mf | %>
			<tr>
				<td><%= link_to mf.name, Rails.configuration.navmine.s3_url + mf.path %></td>
				<td><%= mf.user.name %></td>
				<td><%= mf.created_at.strftime("%Y-%m-%d %H:%M") %></td>

			</tr>
			<% end %>
		</table>

		<%= paginate @monitoring_files, :params => {:controller => 'projects', :action => 'show'} %>

	</div>
	<div class="tab-pane" id="members">

		<table class="table table-striped table-responsive">
			<tr><th>프로젝트 참가자</th>
				<th>관리자기능</th>
			</tr>
			<% @project_users.each do | pu | %>
				<% pu_role = pu.project_role(@project.id) %>
				<tr>
					<td><%= pu.name + "(" + pu.email + ")" %> <span class="label <%= user_role_label(pu_role)%>"><%= user_role_text(pu_role) %></span> 
					</td>
					<% if is_admin(@user_project_role) %>
						<td>	
						<% if is_admin(@user_project_role) %>
							<%= form_tag change_project_role_path, :method => 'post', :class => "form-inline" do %>
								<%= hidden_field_tag(:user_id, pu.id) %>
								<%= hidden_field_tag(:id, @project.id) %>
								<%= select_tag(:role, options_for_select([['Owner', 'owner'], ['Admin', 'admin'],['Viewer', 'viewer']], pu_role)) %>
								<%= submit_tag "변경", :class => "btn btn-xs btn-default" %> 
								<%= link_to "삭제", leave_project_path(@project.id, :user_id => pu.id), :class => "btn btn-xs btn-default", data: { confirm: pu.name + '을 프로젝트에서 제외하시겠습니까?' } %>
							<% end %>
							
						<% end %>
						</td>
					<% end %>
				</tr>
			<% end %>
		</table>

		<% if is_admin(@user_project_role) %>
			<%= link_to "참가자 추가", "", :class => "btn btn-sm btn-default", "data-toggle" => "modal", "data-target" => "#new_member"%>

		<% end %>
	</div>
</div>

<br />

<div class="modal fade" id="new_member">
	<div class="modal-dialog">
		<div class="modal-content">
			<%= form_tag add_project_member_path, :method => 'post' do %>

			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title">프로젝트 멤버 추가</h4>
			</div>
			<div class="modal-body">
				<p>
				<p>
					이메일주소: <%= text_field_tag :email %>
				</p>
				<p>
					프로젝트 역할: <%= select_tag(:role, options_for_select([['Owner', 'owner'], ['Admin', 'admin'],['Viewer', 'viewer']], "viewer")) %>
				</p>

				</p>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">
					닫기
				</button>
				<%= submit_tag "추가", :name => nil, :class => "btn btn-default" %>
			</div>
			<% end %>
		</div><!-- /.modal-content -->
	</div><!-- /.modal-dialog -->
</div><!-- /.modal -->

